import type { VbenFormSchema } from '#/adapter/form';
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { OrderPaymentRecordApi } from '#/api/wedding/orderpaymentrecord';

import { z } from '#/adapter/form';
import {
    DICT_Wedding_TYPE,
    getDictOptions,
    getRangePickerDefaultProps,
} from '#/utils';

/** 新增/修改的表单 */
export function useFormSchema(): VbenFormSchema[] {
  return [
    {
      fieldName: 'id',
      component: 'Input',
      dependencies: {
        triggerFields: [''],
        show: () => false,
      },
    },
    {
      fieldName: 'paymentId',
      label: '支付ID',
      rules: 'required',
      component: 'Input',
      componentProps: {
        placeholder: '请输入支付ID',
      },
    },
    {
      fieldName: 'orderId',
      label: '订单ID',
      rules: 'required',
      component: 'Input',
      componentProps: {
        placeholder: '请输入订单ID',
      },
    },
    {
      fieldName: 'paymentType',
      label: '支付类型(DEPOSIT/BALANCE/FULL)',
      component: 'Select',
      componentProps: {
        options: getDictOptions(DICT_Wedding_TYPE.HandCardTypeStatus.toUpperCase(), 'string'),
        placeholder: '请选择支付类型(DEPOSIT/BALANCE/FULL)',
      },
    },
    {
      fieldName: 'paymentAmount',
      label: '支付金额',
      rules: 'required',
      component: 'Input',
      componentProps: {
        placeholder: '请输入支付金额',
      },
    },
    {
      fieldName: 'paymentMethod',
      label: '支付方式',
      component: 'Input',
      componentProps: {
        placeholder: '请输入支付方式',
      },
    },
    {
      fieldName: 'paymentStatus',
      label: '支付状态',
      component: 'RadioGroup',
      componentProps: {
        options: getDictOptions(DICT_Wedding_TYPE.HandCardTypeStatus.toUpperCase(), 'string'),
        buttonStyle: 'solid',
        optionType: 'button',
      },
    },
    {
      fieldName: 'paymentTime',
      label: '支付时间',
      component: 'DatePicker',
      componentProps: {
        showTime: true,
        format: 'YYYY-MM-DD HH:mm:ss',
        valueFormat: 'x',
      },
    },
    {
      fieldName: 'refundAmount',
      label: '退款金额',
      component: 'Input',
      componentProps: {
        placeholder: '请输入退款金额',
      },
    },
  ];
}

/** 列表的搜索表单 */
export function useGridFormSchema(): VbenFormSchema[] {
  return [
    {
      fieldName: 'paymentId',
      label: '支付ID',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入支付ID',
      },
    },
    {
      fieldName: 'orderId',
      label: '订单ID',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入订单ID',
      },
    },
    {
      fieldName: 'paymentType',
      label: '支付类型(DEPOSIT/BALANCE/FULL)',
      component: 'Select',
      componentProps: {
        allowClear: true,
        options: getDictOptions(DICT_Wedding_TYPE.HandCardTypeStatus.toUpperCase(), 'string'),
        placeholder: '请选择支付类型(DEPOSIT/BALANCE/FULL)',
      },
    },
    {
      fieldName: 'paymentAmount',
      label: '支付金额',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入支付金额',
      },
    },
    {
      fieldName: 'paymentMethod',
      label: '支付方式',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入支付方式',
      },
    },
    {
      fieldName: 'paymentStatus',
      label: '支付状态',
      component: 'Select',
      componentProps: {
        allowClear: true,
        options: getDictOptions(DICT_Wedding_TYPE.HandCardTypeStatus.toUpperCase(), 'string'),
        placeholder: '请选择支付状态',
      },
    },
    {
      fieldName: 'paymentTime',
      label: '支付时间',
      component: 'RangePicker',
      componentProps: {
        ...getRangePickerDefaultProps(),
        allowClear: true,
      },
    },
    {
      fieldName: 'refundAmount',
      label: '退款金额',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入退款金额',
      },
    },
    {
      fieldName: 'createTime',
      label: '创建时间',
      component: 'RangePicker',
      componentProps: {
        ...getRangePickerDefaultProps(),
        allowClear: true,
      },
    },
  ];
}

/** 列表的字段 */
export function useGridColumns(): VxeTableGridOptions<OrderPaymentRecordApi.OrderPaymentRecord>['columns'] {
  return [
    {
      field: 'id',
      title: '',
      minWidth: 120,

    },
    {
      field: 'paymentId',
      title: '支付ID',
      minWidth: 120,

    },
    {
      field: 'orderId',
      title: '订单ID',
      minWidth: 120,

    },
    {
      field: 'paymentType',
      title: '支付类型(DEPOSIT/BALANCE/FULL)',
      minWidth: 120,

    },
    {
      field: 'paymentAmount',
      title: '支付金额',
      minWidth: 120,

    },
    {
      field: 'paymentMethod',
      title: '支付方式',
      minWidth: 120,

    },
    {
      field: 'paymentStatus',
      title: '支付状态',
      minWidth: 120,

    },
    {
      field: 'paymentTime',
      title: '支付时间',
      minWidth: 120,
      formatter: 'formatDateTime',
    },
    {
      field: 'refundAmount',
      title: '退款金额',
      minWidth: 120,

    },
    {
      field: 'createTime',
      title: '创建时间',
      minWidth: 120,
      formatter: 'formatDateTime',
    },
    {
      title: '操作',
      width: 200,
      fixed: 'right',
      slots: { default: 'actions' },
    },
  ];
}

